{% extends 'common/base.html' %}
{% load staticfiles %}

{% block head_js %}
    <script src="{% static 'js/jquery-1.12.4.min.js' %}"></script>
    <script>
        $(function () {
            $('.order_goods_list').each(function () {
                amount =  parseInt($(this).find('.col03').html());
                price = parseFloat($(this).find('.col04').html());
                money = amount * price;
                $(this).find('.col04').html(money + '元');
            })
        })

    </script>

{% endblock head_js %}

{% block body %}

{% include 'common/status.html' %}


	<div class="search_bar clearfix">
 {% include 'common/logo.html' %}
		<div class="sub_page_name fl">|&nbsp;&nbsp;&nbsp;&nbsp;用户中心</div>
		<div class="search_con fr">
			<input type="text" class="input_text fl" name="" placeholder="搜索商品">
			<input type="button" class="input_btn fr" name="" value="搜索">
		</div>
	</div>

	<div class="main_con clearfix">
        {% include 'common/left_menu.html' with flag='order' %}
		<div class="right_content clearfix">
				<h3 class="common_title2">全部订单</h3>

                {% for order in orders %}
                    <ul class="order_list_th w978 clearfix">
                        <li class="col01">{{ order.update_time }}</li>
                        <li class="col02">订单号：{{ order.order_num }}</li>
                        <li class="col02 stress">
                            {% if order.order_status == 1 %}
                                未支付
                            {% elif order.order_status == 2 %}
                                待发货
                            {% elif order.order_status == 3 %}
                                待收货
                            {% elif order.order_status == 4 %}
                                已完成
                            {% endif %}
                        </li>
                    </ul>

                    <table class="order_list_table w980">
                        <tbody>
                            <tr>
                                <td width="55%">
                                    {% for goods in order.goodsdetail_set.all %}
                                        <ul class="order_goods_list clearfix">
                                            <li class="col01"><img src="{% static goods.detail_image %}"></li>
                                            <li class="col02">{{ goods.detail_name }}<em>{{ goods.detail_price }}元/{{ goods.detail_unit }}</em></li>
                                            <li class="col03">{{ goods.detail_amount }}</li>
                                            <li class="col04">{{ goods.detail_price }}</li>
                                        </ul>
                                    {% endfor %}

                                </td>
                                <td width="15%">{{ order.total_money }}元</td>
                                <td width="15%">
                                    {% if order.order_status == 1 %}
                                        未支付
                                    {% elif order.order_status == 2 %}
                                        待发货
                                    {% elif order.order_status == 3 %}
                                        待收货
                                    {% elif order.order_status == 4 %}
                                        已完成
                                    {% endif %}
                                </td>
                                <td width="15%"><a href="#" class="oper_btn">去付款</a></td>
                            </tr>
                        </tbody>
                    </table>
				 {% endfor %}

				<div class="pagenation">
                    {% if paginator.page.has_previous %}
					    <a href="{% url 'users:order' %}?page={{ paginator.page.previous_page_number }}">上一页</a>
                    {% endif %}

                    {% for index in paginator.page_range %}
                        <a href="{% url 'users:order' %}?page={{ index }}" {% if paginator.page == index %} class="active" {% endif %}>{{ index }}</a>
                    {% endfor %}

                    {% if paginator.page.has_next %}
					<a href="{% url 'users:order' %}?page={{ paginator.page.next_page_number }}">下一页></a>
                    {% endif %}
				</div>
		</div>
	</div>

{% endblock body %}
